# Contributor: Alex Denes <caskd@redxen.eu>
# Maintainer:
pkgname=loki-network
pkgver=0.8.2
pkgrel=1
pkgdesc="Lokinet is an anonymous, decentralized and IP based overlay network for the internet."
url="https://lokinet.org/"
arch="all !ppc64le !s390x !armhf !mips64" # Limited by loki-mq
license="GPL-3.0-or-later"
makedepends="cmake libuv-dev>=1.27.0 libsodium-dev>=1.0.18 unbound-dev sqlite-dev>=3 cppzmq nlohmann-json loki-mq-dev linux-headers"
source="https://github.com/loki-project/loki-network/releases/download/v$pkgver/lokinet-v$pkgver.tar.xz"
builddir="$srcdir/lokinet-v$pkgver"
case "$CARCH" in
	x86_64)
	# x86_64 has non-crucial tests failing
	options="$options !check"
	;;
esac

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -S . -B build/ \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_SHARED_LIBS=ON \
		-DSUBMODULE_CHECK=OFF \
		-DWITH_SETCAP=OFF \
		-DWITH_TESTS=ON
	make -C build
}

check() {
	make check -C build
}

package() {
	DESTDIR="$pkgdir" make install -C build
}

sha512sums="0916e075cc05771cd0e4bb12c6f575daa544786c7890ca99091d8c28deac1c050c288b49039cc79164b6206f7fe374f64fa15e79f31986268ae69dfe25573d2e  lokinet-v0.8.2.tar.xz"
